exports.activityList = function (req, res) {

    //获取restful参数
    var restfulParams = req.routeInfo.restfulParams;

    //最终结果
    var resultData = {};

    var forumActivityList = [];

    var nowforumActivityList = [];

    var nowTime = common.nowTime(false);
    //任务流创建
    async.waterfall([

        //获取活动列表
        function (cb) {

            R.SEND_HTTP(
                req,
                {
                    url: CORE_APIConfig.coreAPI.searchForumActivity,
                    method: 'POST',
                    data: {
                        fields: [
                            "fa_id",
                            "fa_title",
                            "fa_image",
                            "fa_a_type",
                            "fa_start_time",
                            "fa_end_time",
                            "fa_old_price",
                            "fa_price"
                        ].join(",")
                    }
                },
                function (err, data) {
                    console.log(nowTime);
                    forumActivityList = data.data;
                    cb();
                }
            );
        },
        function (cb) {

            //创建添加任务
            var tasks = [];

            //循环节点列表
            forumActivityList.forEach(function (item, i) {

                //创建每一个插入任务
                tasks.push(function (cb) {

                    //查询对该用户的回复
                    R.SEND_HTTP(
                        req,
                        {
                            url: CORE_APIConfig.coreAPI.searchFrumActivityAppointment + "/is_delete/0/faa_faid/" + item.fa_id + "/faa_uid/" + restfulParams.u_id,
                            method: 'POST',
                            data: {
                                fields: ["faa_id"].join(",")
                            }
                        },
                        function (err, data) {

                            var is_exist = data.data;

                            if (is_exist.length <= 0) {

                                item.isAppointment = 0;

                            } else {

                                item.isAppointment = 1;

                            }
                            cb();
                        });
                });
            });
            async.waterfall(tasks, cb);
        },
        function (cb) {

            for (var i = 0; i < forumActivityList.length; i++) {
                //活动未结束
                //正在进行&&即将开始
                if (forumActivityList[i].fa_end_time > nowTime) {

                    nowforumActivityList.push(forumActivityList[i]);

                    resultData.nowActivity = nowforumActivityList;

                }
            }
            cb();
        }
    ], function (err, result) {

        //返回最终拼接结果
        RES.response(res, true, resultData);

    });

}